package org.millioncall.yueyoga.admin.export;

import java.util.List;

import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.millioncall.yueyoga.admin.model.ConsumeHistoryModel;

public class ConsumeHistoryExportTemplate extends AbstractExcelExportTemplate {
	private List<ConsumeHistoryModel> records;
	String[] titles = new String[] { "会员编号", "会员姓名", "班级", "课程时间", "老师", "助教", "场地", "产品", "消费时间"};
	public ConsumeHistoryExportTemplate(List<ConsumeHistoryModel> records) {
		this.records = records;
	}

	@Override
	public String[] getSheetNames() {
		return new String[] { "消费记录信息表" };
	}

	@Override
	public String[][] getTitles() {
		return new String[][] { titles };
	}

	@Override
	protected void buildBody(int sheetIndex) {
		Sheet sheet = getSheet(sheetIndex);
		int startIndex = this.getBodyStartIndex(sheetIndex);
		for (int i = 0; i < this.records.size(); i++) {
			ConsumeHistoryModel record = this.records.get(i);
			Row row = sheet.createRow(i + startIndex);
			row.setHeight((short) 300);
			int index = 0;
			String week = record.getWeek();
			String strweek = "";
			if(week == null){
				strweek = "";
			}else{
				strweek = record.getWeek().toString();
			}
			String startTime = record.getScheduleStartTime();
			String strTime = "";
			if(startTime == null){
				strTime = "";
			}else{
				strTime = record.getScheduleStartTime().toString();
			}
			String endTime = record.getScheduleEndTime();
			String enTime = "";
			if(endTime==null){
				enTime = "";
			}else{
				enTime = record.getScheduleEndTime().toString();
			}
			createStyledCell(row, index++, record.getMemberId()==null?"":record.getMemberId().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getMemberName()==null?"":record.getMemberName().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getClassName()==null?"":record.getClassName().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, strweek+""+strTime+"~"+enTime, this.bodyRowStyle);
			createStyledCell(row, index++, record.getScheduleTeacherName()==null?"":record.getScheduleTeacherName().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getScheduleAssistantName()==null?"":record.getScheduleAssistantName().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getSchedulePlaceName()==null?"":record.getSchedulePlaceName().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getProductName()==null?"":record.getProductName().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getConsumeTime()==null?"":record.getConsumeTime().toString(), this.bodyRowStyle);
		}
	}

	@Override
	public String[] getCaptions() {
		return new String[] { "消费记录信息表" };
	}
}

